# encoding: utf-8

import os
import shutil
from glob import glob
import imagehash
from PIL import Image
from tqdm import tqdm

img_path = "../data/origin/*.jpg"

img_list = glob(img_path)
print(len(img_list))

hash_map = {}

for img in tqdm(img_list):
    dhash = imagehash.dhash(Image.open(img))
    if dhash in hash_map.keys():
        os.remove(img)
    else:
        hash_map[dhash] = 1
